TARGET = libexpat.so

NAMETAB = lib/nametab.h

# If you know what your system's byte order is, define XML_BYTE_ORDER:
# use -DXML_BYTE_ORDER=12 for little-endian byte order;
# use -DXML_BYTE_ORDER=21 for big-endian (network) byte order.
# -DXML_NS adds support for checking of lexical aspects of XML namespaces spec
# -DXML_MIN_SIZE makes a smaller but slower parser
# -DXML_DTD adds full support for parsing DTDs
CFLAGS += -DXML_NS -DXML_DTD
CFLAGS += -fPIC
CFLAGS += -Ilib

LIBOBJS = 	lib/xmltok.o \
  			lib/xmlrole.o \
  			lib/xmlparse.o


HEADERS = $(wildcard lib/*.h)
HEADERS += lib/xmltok_impl.c
HEADERS += lib/xmltok_ns.c

GENNMTAB_EXE = gennmtab/gennmtab
GENNMTAB_OBJS = gennmtab/gennmtab.o

all: $(TARGET)
	cp $(TARGET) $(XML_LIB_DIR)
	cp $(HEADERS) $(XML_INC_DIR)
	@echo "###################################"
	@echo "#        $(TARGET) "
	@echo "#        Build up successfully"
	@echo "###################################"		


$(TARGET): $(NAMETAB) $(LIBOBJS)
	$(CC) $(CFLAGS) -shared $(LIBOBJS) -o $@  $(LDFLAGS)

$(NAMETAB): $(GENNMTAB_EXE)
	rm -f $@
	$(GENNMTAB_EXE) > $@

$(GENNMTAB_EXE): $(GENNMTAB_OBJS)
	$(CC) $(CFLAGS) -o $@ $(GENNMTAB_OBJS)

%.o:%.c
	$(CC) $(CFLAGS) -c -o $@ $<

clean:
	@echo "###################################"
	@echo "#        clean $(TARGET) "
	@echo "###################################"		
	rm -f $(LIBOBJS) $(NAMETAB) $(TARGET) $(GENNMTAB_EXE) $(GENNMTAB_OBJS)

